package com.c.ctgproject.ui.storage.material

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.utils.awaitSync
import com.c.ctgproject.utils.handlerBody
import com.c.ctgproject.utils.launch
import com.c.ctgproject.utils.userToken

class StorageMaterialOutDetailViewModel : BaseViewModel() {
    private val mConfirmResult = MutableLiveData<String>()
    val confirmResult: LiveData<String> get() = mConfirmResult


    fun confirm(materialSalesOrderId: String, materialId: Int, outWeight: Int, outNum: Int) {
        launch {
            mConfirmResult.value = ApiMethods.getApiService().storageMaterialDetailConfirm(
                userToken,
                handlerBody(
                    "materialSalesOrderId" to materialSalesOrderId,
                    "materialId" to materialId,
                    "outWeight" to outWeight,
                    "outNum" to outNum
                )
            ).awaitSync()
        }
    }
}